#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2021/7/12 12:36 下午
# @Author  : WangZhixing


from sklearn.metrics.cluster import (v_measure_score, homogeneity_score, completeness_score)


def Cluster_Metric(labels, pred):
    completeness = completeness_score(labels, pred)
    # 聚类的完成性
    # completeness:所有的同类的都被分在一起的概率，
    # completeness_score([0, 0,1,1], [0, 0,1,1])=1
    # print(completeness_score([0, 0,1,1], [0, 0,3,3]))
    homogeneity = homogeneity_score(labels, pred)
    # 一个聚类结果满足同质性，如果它的所有聚类仅包含作为单个类成员的数据点。
    vmeasure = v_measure_score(labels, pred)
    return completeness, homogeneity, vmeasure
